package per.chao.mqtt.domain.util;

import org.springframework.stereotype.Component;

import java.util.Timer;
import java.util.TimerTask;

/**
 * Description: 定时任务，简单轮询查看内存缓存中的在线用户和订阅topic
 *
 * @author W.Chao
 * @date 2021/6/25 22:43
 **/
@Component
public class TaskCircle {
	private static final Timer timer = new Timer("task-circle");

	public static void addTask(TimerTask task, long delay, long period) {
		timer.scheduleAtFixedRate(task, delay, period);
	}

	public static void addTask(TimerTask task, long period) {
		timer.scheduleAtFixedRate(task, 0, period);
	}
}
